package com.example.testapplication;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;

import com.example.testapplication.adapter.RecyclerAdapter;
import com.example.testapplication.bean.RecylerItem;

import java.util.ArrayList;
import java.util.List;

public class RecyclerViewItem extends AppCompatActivity {

    private RecyclerView mRecyclerView;
    private List<RecylerItem> dataBeanList;
    private RecylerItem dataBean;
    private RecyclerAdapter mAdapter;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recycler_view_item);
        mRecyclerView = (RecyclerView) findViewById(R.id.recycle_view);
        initData();
    }

    /**
     *  模拟数据
     * **/

    private void initData(){
        dataBeanList = new ArrayList<>();
        for(int i = 1; i<=50;i++){
            dataBean = new RecylerItem();
            dataBean.setID(i+"");
            dataBean.setType(0);
            dataBean.setParentLeftTxt("父--" +i);
            dataBean.setChildRightTxt("父内容" +i);
            dataBean.setChildLeftTxt("子--" +i);
            dataBean.setParentRightTxt("子内容---" + i);
            dataBean.setChildBean(dataBean);
            dataBeanList.add(dataBean);
        }

        setData();

    }

    private void setData(){
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        mAdapter = new RecyclerAdapter(this,dataBeanList);
        mRecyclerView.setAdapter(mAdapter);

    }
}